<template>
  <a-card :bordered='false'>
    <!-- 操作按钮区域 -->
    <!-- table区域-begin -->
    <div>
      <a-table
        ref='table'
        size='middle'
        :scroll='{x:true}'
        bordered
        rowKey='id'
        :columns='columns'
        :dataSource='dataSource'
        :pagination='ipagination'
        :loading='loading'
        class='j-table-force-nowrap'
        @change='handleTableChange'>
        <template slot='taskDes' slot-scope='text'>
          <j-ellipsis :value='text' :length='10' />
        </template>
        <template slot='htmlSlot' slot-scope='text'>
          <div v-html='text'></div>
        </template>
        <template slot='imgSlot' slot-scope='text'>
          <span v-if='!text' style='font-size: 12px;font-style: italic;'>无图片</span>
          <img v-else :src='getImgView(text)' height='25px' alt=''
               style='max-width:80px;font-size: 12px;font-style: italic;' />
        </template>
        <template slot='fileSlot' slot-scope='text'>
          <span v-if='!text' style='font-size: 12px;font-style: italic;'>无文件</span>
          <a-button
            v-else
            :ghost='true'
            type='primary'
            icon='download'
            size='small'
            @click='downloadFile(text)'>
            下载
          </a-button>
        </template>
      </a-table>
    </div>
  </a-card>
</template>

<script>

import '@/assets/less/TableExpand.less'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction } from '@api/manage'
import { filterDictTextByCache } from '@comp/dict/JDictSelectUtil'


export default {
  name: 'HfPmProjectRisksList',
  mixins: [JeecgListMixin],
  components: {},
  data() {
    return {
      description: '风险详情',
      disableMixinCreated:true,
      // 表头
      columns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '风险编号',
          align: 'center',
          dataIndex: 'riskCode',
        },
        {
          title: '专题名称',
          align: 'center',
          dataIndex: 'subjectName',
          scopedSlots: { customRender: 'taskDes' }
        },
        {
          title: '风险类型',
          align: 'center',
          dataIndex: 'riskType',
          customRender: (t) => {
            return filterDictTextByCache('risk_type', t) || '--'
          }
        },
        {
          title: '风险等级',
          align: 'center',
          dataIndex: 'riskGrade',
          customRender: (t) => {
            return filterDictTextByCache('risk_grade', t) || '--'
          }
        },
        {
          title: '风险描述',
          align: 'center',
          dataIndex: 'riskDes',
          scopedSlots: { customRender: 'taskDes' }
        },
        {
          title: '影响分析',
          align: 'center',
          dataIndex: 'affect',
          scopedSlots: { customRender: 'taskDes' }
        },
        {
          title: '应对措施',
          align: 'center',
          dataIndex: 'solutions',
          scopedSlots: { customRender: 'taskDes' }
        },
        {
          title: '风险负责人',
          align: 'center',
          dataIndex: 'dutyPersion'
        },
        {
          title: '确认人',
          align: 'center',
          dataIndex: 'confirmorName'
        },
        {
          title: '确认时间',
          align: 'center',
          dataIndex: 'confirmorTime'
        }
      ],
      url: {
        queryByProjectId: '/pm/hfPmProjectRisks/queryByProjectId'
      },
      dictOptions: {}
    }
  },
  created() {

  },
  computed: {},
  methods: {
    getListByProjectId(projectId) {
      getAction(this.url.queryByProjectId, { projectId }).then((res) => {
        if (res.success) {
          // this.dataSource = res.result
          this.dataSource = res.result.records || res.result
        } else {
          this.$message.warning('操作失败！')
        }
      })
    },
    initDictConfig() {
    }


  }

}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>